import React, {Component} from 'react';

import store from './store'

class Cmp1 extends Component{
  constructor(...args){
    super(...args);

    this.state={
      user_count: store.getState().user.count,
      company_count: store.getState().company.count
    };

    store.subscribe(()=>{
      this.setState({
        user_count: store.getState().user.count,
        company_count: store.getState().company.count
      });
    });
  }

  render(){
    return <div>
      <span>用户量：{this.state.user_count}</span>
      <br/>
      <span>企业用户：{this.state.company_count}</span>
    </div>;
  }
}

export default Cmp1;
